# 利用双端队列，对先后从首端、尾端移除的字符进行比较，如果每次移除的两个字符都相等，且直到剩余个数小于等于1个字符的时候，则判定属于回文词

from pythonds.basic.deque import Deque

def palchecker(aString):
    chardeque = Deque()
    
    for ch in aString:
        chardeque.addRear(ch)
    stillEqual = True
    while chardeque.size() > 1 and stillEqual:
        first = chardeque.removeFront()
        last = chardeque.removeRear()
        if first != last:
            stillEqual = False
    
    return stillEqual

if __name__ == "__main__":
    print(palchecker('abcdefedcba'))
    print(palchecker('九九重阳节，岁岁频登高'))
    